import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	  playerState:'',// 当前音频播放状态
	  playList:[],// 当前播放列表
	  playingIndex:null,
	  playLyric:'',
	  currentSong:{
		  al:{},
	  },
	  currentTime:0,
	  currentDuration:0
  },
  mutations: {
	  setCurrentSong(state,date){
		  state.currentSong = date;
		  // console.log(date)
		  // console.log(state.currentSong.ar[0].name)
		  state.currentSong.ar.forEach((item)=>{
			  console.log(item.name)
		  })
	  },
	  changePlayerState(state,type){
		  console.log(type)
		  state.playerState = type;
	  },
	  playListState(state,idList){
		  console.log(idList)
		  state.playList = idList
	  },
	  setPlayingIndex(state,index){
		  state.playingIndex = index
	  },
	  preSong(state){
		  if(state.playingIndex == 0){
			  state.playingIndex = state.playList.length-1;
		  }else{
			  state.playingIndex--
		  }
	  },
	  nextSong(state){
		  if(state.playingIndex == state.playList.length-1){
			  state.playingIndex = 0;
		  }else{
			  state.playingIndex++
		  }
	  },
	  getCurrentTime(state,data){
		  state.currentTime = data.curTime;
		  state.currentDuration = data.curDuration
	  },
	  currentLyric(state,playlyric){
		  state.playLyric = playlyric
	  }
  },
  actions: {
  },
  modules: {
  }
})
